//
//  GXTipsButtonView.m
//  GXInformationDemo
//
//  Created by 甘霞 on 15/10/22.
//  Copyright © 2015年 甘霞. All rights reserved.
//

#import "GXTipsButtonView.h"

@implementation GXTipsButtonView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    //按钮
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *buttonImage = [[UIImage imageNamed:@"icon-afternoon-tea-entry"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
    [self.button setAlpha:0.5];
    [self.button setFrame:CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height)];
    self.button.layer.cornerRadius = buttonImage.size.width / 2.0;
    self.button.layer.masksToBounds = YES;
    [self addSubview:self.button];
    
    if (!self.isHideImageView) {
        //imageView
        UIImage *image = [UIImage imageNamed:@"icon-has-new-tea"];
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(buttonImage.size.width - image.size.width, -5, image.size.width, image.size.height)];

        self.imageView.layer.cornerRadius = image.size.width / 2.0;
        self.imageView.layer.masksToBounds = YES;
        [self addSubview:self.imageView];
    }
}

- (void)addTarget:(id)target action:(SEL)action {
    [self.button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

@end
